import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';

class CachedImageApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final String appTitle = 'Cached Images';
    return MaterialApp(
      title: appTitle,
      theme: ThemeData(primarySwatch: Colors.red),
      home: CachedImageAppPage(title: appTitle),
    );
  }
}

class CachedImageAppPage extends StatefulWidget {
  final String title;

  CachedImageAppPage({Key key, this.title}) : super(key: key);

  @override
  State<StatefulWidget> createState() => CachedImageAppPageState();
}

class CachedImageAppPageState extends State<CachedImageAppPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: CachedNetworkImage(
          placeholder: CircularProgressIndicator(),
          imageUrl:
              'http://image.baidu.com/search/down?tn=download&word=download&ie=utf8&fr=detail&url=http%3A%2F%2Fpic.58pic.com%2F58pic%2F13%2F80%2F78%2F35V58PICrWD_1024.jpg&thumburl=http%3A%2F%2Fimg1.imgtn.bdimg.com%2Fit%2Fu%3D2569486047%2C3428433554%26fm%3D26%26gp%3D0.jpg',
        ),
      ),
    );
  }
}
